import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;

public class TimeSheet extends HttpServlet
{
 public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException ,IOException
 {
  
     PrintWriter pw=resp.getWriter();
     resp.setContentType("text/html");

try
{ 
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection con =   DriverManager.getConnection("jdbc:odbc:psi","psi","psi");
  System.out.println("connection is created"+con);
  String  EMP_CODE=req.getParameter("e");
  String  PRO_CODE=req.getParameter("p");
int k=Integer.parseInt(PRO_CODE);
String  EMP_NAME=req.getParameter("ename");
String  PRO_NAME=req.getParameter("pname");
String  PRO_SDATE=req.getParameter("psd");
String  TAR_DATE=req.getParameter("td1");
String ACT_SDATE=req.getParameter("asd");
System.out.println("activity type"+ACT_SDATE);
String ACT_EDATE=req.getParameter("aed");
String PRO_HOURS=req.getParameter("ph");
int j=Integer.parseInt(PRO_HOURS);
String  ACT_HOURS=req.getParameter("ah");
int i=Integer.parseInt(ACT_HOURS);
System.out.println("activity type"+i);
String submit=req.getParameter("vittu");
System.out.println("submit value"+submit);
  Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
if(submit.equals("Save"))
  	{
     
 PreparedStatement pstmt=con.prepareStatement("insert into time_analysis  values(?,?,?,?,?,?,?,?,?,?)");
 	pstmt.setString(1,EMP_CODE);
	 pstmt.setInt(2,k);
	 pstmt.setString(3,EMP_NAME);
 	pstmt.setString(4, PRO_NAME);
 	pstmt.setString(5,PRO_SDATE);
	pstmt.setString(6,TAR_DATE);
	pstmt.setString(7,ACT_SDATE);
	pstmt.setString(8,ACT_EDATE);
	pstmt.setInt(9,j);
	pstmt.setInt(10,i);
	
	                  pstmt.executeUpdate(); 
               }   
resp.setHeader("REFRESH","2;URL=./timesheet-details.htm");
}
catch(Exception e)
{
 e.printStackTrace();
 }
}
 }